package appconfig

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	Mysql
	RealnameAuth
}
type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type RealnameAuth struct {
	SecretId  string
	SecretKey string
}

var Appconf AppConfig

func Init() {
	var err error
	viper.SetConfigFile("appconfig/dev.yaml")
	if err = viper.ReadInConfig(); err != nil {
		panic("读取配置文件失败" + err.Error())
	}
	if err = viper.Unmarshal(&Appconf); err != nil {
		panic("解析配置文件失败" + err.Error())
	}
	logx.Info("动态配置数据文件成功", Appconf)
}
